-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use nostr as cache system #1362
Conversation
8d8e716
to
fa90ccc
Compare
@KoalaSat nice idea, and really needed once the number of coordinators starts to grow. :) |
The reason behind is that wherever the token comes from, we ask for coordinators if the token exists, in case there are active or past orders for it. Certainty, we know when the token is created but that would involve to fetch the coordinator every time the user tries to create an order, affecting the waiting time (unknown robots can´t create an order). It's tricky to find an efficient way and don´t affect other parts, specially because the app/api assumes my robot is known, and for example, we would have to handle it in case the user visits their profile. Anyways itś good to raise this topic from time to time to figure out if there are better ways |
In roboauto I have that when creating a robot, the user have to specifiy a coordinator, and when recovering a robot, together with the secret also the coordinator have to be specified. |
Good to know, my plan with this cache service was also very related to this topic, cache book can also store on goings orders, and if you download it and just search on it your robot name thatś another nice way to know there is an order for your robot, as far the cache system is reliable enought 😄 |
Ah yes this is even better, if the cache book keeps also track of ongoing orders, the user needs just the secret. The client can calculate the robot name from the secret, then search for his coordinator in the cache book. So there is never the need to search all coordinators to check if the robot is present and have an order. |
db49deb
to
c4452b7
Compare
docker/strfry/crontab
Outdated
# For more information see the manual pages of crontab(5) and cron(8) | ||
# | ||
# m h dom mon dow command | ||
*/1 * * * * torsocks /app/sync.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torfication of sync calls are done as part of the cron command to avoid mistakes if the coordinator modifies sync.sh
https://github.com/RoboSats/robosats/pull/1362/files#diff-366e6549a96aec09107bfc5f3f3804f92cfee8d9804bc8b222136d0a0a15d08b
9692a7e
to
5000155
Compare
7cba270
to
b658679
Compare
b658679
to
032a48a
Compare
1b02f30
to
1c7b2a8
Compare
tested and working in Satstralia 👍 |
Tested in Satstralia for 3 weeks already and fully working! 🚀 |
What does this PR do?
This is a first POC. I'm exploring to use nostr not as primary DB but as a cache system of a decentralized network such as the federation of Robosats, right now a client has to directly connect to every single coordinator book to fetch its specific orders.
Centralizing this system would create a single point of failure, so I'm exploring a federation cache network, where the full book is aditioanlly stored and maintained by coordinators, allowing users to initially connect just to 2-3 coordinators. any feedback is welcome 🙂
For now this PR just creates a coordinator relay and sends an event every time a new order is created. The note follows this on going NIP nostr-protocol/nips#1331
As additional win, this will allow Robosats to quickly integrate others' platforms orders with just a single implementation
Federation cache
Every relay of the federation will be in sync with the others, containing all orders available in the federation:
The federation will keep a strong negentropy circle between their relays, but any other external relay will be able to fetch or create new order events. Because it's just cache, we can leave the creation of events open to anyone, if it becomes a spam problem, it can be cleaned up automatically by coordinators.
Clients will always send requests filtering by coordinators' public keys, that way spam or fake orders will never reach to the user.
How to test
Publish an order. Connect your WS tools to
ws://localhost:12596/nostr
and send:You should get in return:
Any change on the order should remove previous note and create a new one (identified over time by its
d
tag). To keep privacy, Robosats will only have 2 order statuses:pending
andsuccess
.Checklist before merging
pip install pre-commit
, thenpre-commit install
. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.